package common;

import java.util.Arrays;

public class bubbleSort {

    public <Val extends Comparable<Val>> void run(Val[] vals) {
        int len = vals.length;
        for (int j = 0; j < len - 1; j++) {
            for (int i = 0; i < len - j - 1; i++) {
                if (vals[i].compareTo(vals[i + 1]) > 0) {
                    Val tmp = vals[i];
                    vals[i] = vals[i + 1];
                    vals[i + 1] = tmp;
                }
            }
        }
    }

    public static void main(String[] args) {
        Integer[] arr = {3, 54, 62, 34, 6768, 79, 8};
        bubbleSort sort = new bubbleSort();
        sort.run(arr);
        System.out.println(Arrays.toString(arr));
    }
}
